﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ExtensibleEventViewer.Core.Primitives;

namespace ExtensibleEventViewer.Console.Forms
{
	public partial class EventLogRecordDetailsWnd : FormBase
	{
		public EventLogRecordDetailsWnd()
		{
			InitializeComponent();
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			if(HideOnClose)
			{
				Hide();
			}
			else
			{
				Close();
			}
		}

		protected override void OnClosing(CancelEventArgs e)
		{
			if (HideOnClose)
			{
				e.Cancel = true;
				Hide();
			}

			base.OnClosing(e);
		}

		private void btnCopyToClipboard_Click(object sender, EventArgs e)
		{
			Clipboard.SetText(erdDetails.EventLogRecordDescription);
		}

		public void ShowEventLogRecordDetails(
			string logName, 
			EventLogRecord eventLogRecordToDisplay, 
			Func<EventLogRecord, string> descriptionProcessor)
		{
			erdDetails.ShowEventLogRecordDetails(logName, eventLogRecordToDisplay, descriptionProcessor);
		}

		public bool HideOnClose
		{
			get;
			set;
		}
	}
}
